package com.xqboss.apps.domain.sys;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xqboss.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 配置-积分配置
 * </p>
 *
 * @author lang.liu
 * @since 2022-02-21
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value = "SysConfIntegral对象", description = "配置-积分配置")
public class SysConfIntegral extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "积分名称")
    private String integralName;

    @ApiModelProperty(value = "积分图标")
    private String integralImg;

    @ApiModelProperty(value = "积分功能")
    private Boolean integral;

    @ApiModelProperty(value = "直购赠送")
    private Boolean buyGive;

    @ApiModelProperty(value = "开箱赠送")
    private Boolean boxGive;

    @ApiModelProperty(value = "直购抵现")
    private Boolean buyCash;

    @ApiModelProperty(value = "开箱抵现")
    private Boolean boxCash;

    @ApiModelProperty(value = "奖品分解")
    private Boolean prizeDecompose;

    @ApiModelProperty(value = "兑换商城")
    private Boolean exchangeMall;

    @ApiModelProperty(value = "积分比例")
    private BigDecimal integralProportion;

    @ApiModelProperty(value = "分解比例")
    private BigDecimal resolveCoefficient;

    @ApiModelProperty(value = "交易说明")
    private String transactionDesc;

    @ApiModelProperty(value = "分解说明")
    private String decompositionDesc;

    @ApiModelProperty(value = "转增说明")
    private String giveDesc;

    @ApiModelProperty(value = "类型  1玉珠 2天珠 3灵珠")
    private Integer type;
    @ApiModelProperty(value = "是否开启抵扣 1开启 0不开启")
    private Integer isCash;
    @ApiModelProperty(value = "1固定 2动态")
    private Integer state;
    @ApiModelProperty(value = "是否开启抵扣溢价 1开启 0不开启")
    private Integer isPremium;

    @TableLogic(value = "null", delval = "now()")
    @JsonIgnore
    private Date deleteTime;
    public enum ExplainEnum {

        /**
         * 分解说明 code:1
         */
        DECOMPOSITION_DESC("分解说明", 1),
        /**
         * 交易说明 code:2
         */
        TRANSACTION_DESC("交易说明", 2);

        private String message;
        private int code;

        ExplainEnum(String message, int code) {
            this.message = message;
            this.code = code;
        }

        public String getMessage() {
            return message;
        }

        public void setMessage(String message) {
            this.message = message;
        }

        public int getCode() {
            return code;
        }

        public void setCode(int code) {
            this.code = code;
        }

        public static ExplainEnum getByCode(int code) {
            ExplainEnum[] enums = values();
            for (ExplainEnum enumItem : enums) {
                if (enumItem.getCode() == code) {
                    return enumItem;
                }
            }
            return null;
        }

        public static ExplainEnum getByMessage(String message) {
            ExplainEnum[] enums = values();
            for (ExplainEnum enumItem : enums) {
                if (enumItem.getMessage().equals(message)) {
                    return enumItem;
                }
            }
            return null;
        }
    }
}
